
package javaapplication2;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class ObjectOutputStreamDemo {
    public static void main(String[] args) {
      int i = 319874;
      try {
         FileOutputStream out = new FileOutputStream("test.txt");
         ObjectOutputStream oout = new ObjectOutputStream(out);
         oout.writeInt(i);
         oout.writeInt(1653984);
         oout.flush();
         oout.close();
         ObjectInputStream ois =new ObjectInputStream(new FileInputStream("test.txt"));
         System.out.println("" + ois.readInt());
         System.out.println("" + ois.readInt());
      } catch (Exception ex) {
         ex.printStackTrace();
      }

   }
}
